package com.yhy.wxzn.wcs.device.rgv.enums;

import com.yhy.wxzn.wcs.device.rgv.bean.Node;

import java.util.List;

public enum RunningDirection {
    /**
     * （从小车电池方向看过去）1左2右3上4下
     */

    左(2),
    右(1),
    上(3),
    下(4);
    private int cmd;

    RunningDirection(int cmd) {
        this.cmd = cmd;
    }


    public int getCmd() {
        return cmd;
    }


    public static RunningDirection getDirect(List<Node> nodes){
        Node n1 = nodes.get(0);
        Node n2 = nodes.get(1);

        if (!Node.isStraight(n1,n2))
            throw new RuntimeException(String.format("%s %s不在一条直线上",n1.toString(),n2.toString()));

        if (n2.getX() < n1.getX())
            return 上;
        if (n2.getX() > n1.getX())
            return 下;
        if (n2.getY() < n1.getY())
            return 左;

        return 右;
    }


}